package com.keqing.tomato.bean;

import com.keqing.tomato.util.TimeUtil;

import java.util.Date;

public class GroupInfo {
    private String dateStr;
    private Date date;
    private int durationSum;
    private int historyCount;

    public GroupInfo() {
    }

    public GroupInfo(String dateStr, int durationSum, int historyCount) {
        this.dateStr = dateStr;
        this.durationSum = durationSum;
        this.historyCount = historyCount;
    }

    public GroupInfo(Date date, int durationSum, int historyCount) {
        this.date = date;
        if(TimeUtil.isCurrentYear(date)){
            this.dateStr = TimeUtil.getStringByFormat(date, TimeUtil.dateFormatMDofChinese);
        }else{
            this.dateStr = TimeUtil.getStringByFormat(date, TimeUtil.dateFormatYMDofChinese);
        }
        if (TimeUtil.isToday(date)){
            this.dateStr = "今天，"+ this.dateStr;
        }
        if(TimeUtil.isYesterday(date)){
            this.dateStr = "昨天，"+ this.dateStr;
        }
        this.durationSum = durationSum;
        this.historyCount = historyCount;
    }

    public String getDateStr() {
        return dateStr;
    }

    public void setDateStr(String dateStr) {
        this.dateStr = dateStr;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public int getDurationSum() {
        return durationSum;
    }

    public void setDurationSum(int durationSum) {
        this.durationSum = durationSum;
    }

    public int getHistoryCount() {
        return historyCount;
    }

    public void setHistoryCount(int historyCount) {
        this.historyCount = historyCount;
    }

    public void changeValue(Date date, int durationSum, int historyCount) {
        this.date = date;
        if(TimeUtil.isCurrentYear(date)){
            this.dateStr = TimeUtil.getStringByFormat(date, TimeUtil.dateFormatMDofChinese);
        }else{
            this.dateStr = TimeUtil.getStringByFormat(date, TimeUtil.dateFormatYMDofChinese);
        }
        if (TimeUtil.isToday(date)){
            this.dateStr = "今天，"+ this.dateStr;
        }
        if(TimeUtil.isYesterday(date)){
            this.dateStr = "昨天，"+ this.dateStr;
        }
        this.durationSum = durationSum;
        this.historyCount = historyCount;
    }
}
